<style>
.layui-input-block{
margin-left:120px;
}
</style>
<form class="layui-form" action="" id="orderEditForm">
<!-- 隐藏域用于传递ID th:value="${order.id}"-->
 <input type="hidden" name="id" class="layui-input"  th:value="${obj.id}"/>
 <div class="layui-row"  style="margin-top:10px;">

	 <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">姓名</label>
		    <div class="layui-input-block" style="width:200px;">
		         <input type="text" name="name" class="layui-input" lay-verify="required" th:value="${obj.name}"/>
		    </div>
	   </div>
	
	<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">手机号</label>
		    <div class="layui-input-block" style="width:200px;">
		         <input type="text" name="phone" class="layui-input" lay-verify="required|phone" th:value="${obj.phone}"/>
		    </div>
	   </div>
  </div>
  
  
 <div class="layui-row" style="margin-top:10px;">
 
 	<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">邮箱</label>
		    <div class="layui-input-block" style="width:200px;">
		         <input type="text" name="email" class="layui-input" lay-verify="required|email" th:value="${obj.email}"/>
		    </div>
	   </div>
  	 
<!--   	 <div class="layui-col-xs6 layui-col-sm6 layui-col-md6"> -->
<!-- 		    <label class="layui-form-label" style="width:120px;">密码</label> -->
<!-- 		    <div class="layui-input-block" style="width:200px;"> -->
<!-- 		         <input type="text" name="password" class="layui-input" lay-verify="required"/> -->
<!-- 		    </div> -->
<!-- 	   </div> -->

  	  	  <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">角色名称</label>
		    <div class="layui-input-block" style="width:200px;">
				<select name="roleId" id="roleId" lay-verify="required">
					<option th:each="ec:${sysRoleList}" th:value="${ec.id}" th:text="${ec.name}" th:selected="${ec.id} == ${obj.roleId}" ></option>
				</select>
		    </div>
	   </div>
    
 </div>
 
  <div class="layui-row" style="margin-top:10px;">
  
  	 
  	 <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">所属公司</label>
		    <div class="layui-input-block" style="width:200px;">
				<select name="companyId" id="companyId" lay-verify="required">
					<option th:each="ec:${actCenterCompanyMap}" th:value="${ec.id}" th:text="${ec.name}" th:selected="${ec.id} == ${obj.companyId}" ></option>
				</select>
		    </div>
	   </div>
	   
	    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">状态</label>
		    <div class="layui-input-block" style="width:200px;">
				<select name="status" id="status" lay-verify="required">
					<option th:each="ec:${statusList}" th:value="${ec.key}" th:text="${ec.val}" th:selected="${ec.key} == ${obj.status}"></option>
				</select>
		    </div>
	   </div>
	  
  </div>
  <div class="layui-row" style="margin-top:10px;">
  
  	
  		<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">类型</label>
		    <div class="layui-input-block" style="width:200px;" >
				<select name="type" id="type" lay-verify="required" lay-filter="typechange">
					<option th:each="ec:${typeList}" th:value="${ec.code}" th:text="${ec.value}" th:selected="${ec.code} == ${obj.type}"></option>
				</select>
		    </div>
	   </div>
	   
	    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">一级返点</label>
		    <div class="layui-input-block" style="width:200px;">
				 <input type="text" name="first"  readonly="true" style="background-color:#ececec" class="layui-input rebate" th:value="${obj.first}"/>
		    </div>
	   </div>
  </div>
  
   <div class="layui-row" style="margin-top:10px;">
  
  	
  		<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">二级返点</label>
		    <div class="layui-input-block" style="width:200px;" >
				 <input type="text" name="second"  readonly="true" style="background-color:#ececec" class="layui-input rebate" th:value="${obj.second}" />
		    </div>
	   </div>
	   
	   	<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
		    <label class="layui-form-label" style="width:120px;">三级返点</label>
		    <div class="layui-input-block" style="width:200px;" >
				 <input type="text" name="three"  readonly="true" style="background-color:#ececec" class="layui-input rebate" th:value="${obj.three}"/>
		    </div>
	   </div>
  </div>
  
  <div class="layui-row" style="margin-top:10px;">
  
  
	  <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
	    <label class="layui-form-label" style="width:120px;" lay-filter="">备注</label>
	    <div class="layui-input-block" style="width:200px;">
		    <textarea rows="6" cols="74" name="remark" resize="no" th:text="${obj.remark}"></textarea>
	    </div>
	   </div>
  </div>
  
 <div class="layui-row" style="margin-top:20px;">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" style="text-align:center;">
          <button class="layui-btn" lay-submit="" lay-filter="formSubmit" authcode="900338">提交</button>
      	<button type="button" class="layui-btn layui-btn-primary" id="closeBtn">关闭</button>
    </div>
  </div>

</form>
<script>

//start use
layui.use('form', function(){
	
	  var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
	  //……
	  //但是，如果你的HTML是动态生成的，自动渲染就会失效
	  //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
	  form.render();
	//监听表单提交
	form.on('submit(formSubmit)',function(data) {
		$.ajax({url:'/sys/user/edit_execute',
			data:$("#orderEditForm").serializeJson(),
			type:"get",
			contentType:"application/json",
			success:function(data){
				if(data.code==200){
					layer.msg("数据保存成功！");
					reloadData();
					layer.closeAll();
				}else{
					layer.msg(data.message);
				}
			}});
		return false;
	});
	form.on('select(typechange)',function(data) {
		if(data.value == 2) {
			$(".rebate").each(function(i) {
				$(this).removeAttr("readonly");//去除input元素的readonly属性 
				$(this).css("background-color",""); 
			});
		}else{
			$(".rebate").each(function(i) {
				$(this).attr("readonly","true");
				$(this).css("background-color","#ececec");
				$(this).val("");
			});
		}
	});

	 function reloadData(){
			$(".layui-laypage-btn")[0].click();//页面的确定按钮
		}
	$('#closeBtn').click(function() {
		layer.close(editdialogindex);
	});
});
//end use
</script>
<script>
$(function() {
	var typeval = $("#type option:selected").val()
	console.log(typeval);
	if(typeval == 2) {
		$(".rebate").each(function(i) {
			$(this).removeAttr("readonly");//去除input元素的readonly属性 
			$(this).css("background-color",""); 
		});
	}
});
</script>
